<template>
  <div class="audition20">
    <p>原理是原型链查找。如果左边的量沿着__proto__能找到右边的量的prototype，则返回true</p>
    <p>所以，instanceof不能用来判断基本数据类型</p>
    <p>手动实现instanceof：</p>
    <v-md-preview :text="text1" />
  </div>
</template>

<script>
const prefix = '``` js'
const suffix = '```'
export default {
  name: 'Audition207',
  data() {
    return {
      text1: `${prefix}
      function _instanceof(left, rig) {
        rig = rig.prototype
        left = left.__proto__
        while(true) {
          if(left === null) {
            return false
          }
          if(left === rig) {
            return true
          }
          left = left.__proto__
        }
      }
      \n${suffix}`,
    }
  }
}
</script>

<style>

</style>